package com.frank.asynService.web;

import com.frank.asynService.service.AsynService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;

/**
 * @author 小石潭记
 * @date 2020/10/27 11:46
 * @Description: ${todo}
 */
@RestController
@RequestMapping("/async")
public class AsynTaskController {

    @Autowired
    public AsynService asynService;

    @RequestMapping("/index")
    public String  asyncTask() throws ExecutionException, InterruptedException {
        asynService.async();
        asynService.asyncInvokeSimplest();
        asynService.asyncInvokeWithParameter("test");
        Future<String> stringFuture = asynService.asyncInvokeReturnFuture(100);
        System.out.println("-----------" + stringFuture.get());
        return "async task";
    }

}
